package com.google.common.primitives;

import com.google.common.base.Preconditions;

public class Shorts {
    public static short checkedCast(long value) {
        short result = (short) value;
        Preconditions.checkArgument(result == value, "Out of range: %s", value);
        return result;
    }

    public static short fromBytes(byte b1, byte b2) {
        return (short) ((b1 << 8) | (b2 & 0xFF));
    }
}
